package com.hczt.xhminiapp.db.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

/**
 * @author 红创-马海强
 * @date 2019-03-13 14:33
 * @description
 */
@Data
@Entity
@Table(name = "t_sys_role")
public class SysRole implements Serializable {

    private static final long serialVersionUID = -700339664798668307L;
    @Id
    @GenericGenerator(name = "idGenerator", strategy = "uuid")
    @GeneratedValue(generator = "idGenerator")
    @Column(name = "role_id", length = 40)
    private String  roleId;

    private String  roleName;

    private String  roleCode;

    private Boolean enabled;

    @Column(name = "create_time", updatable = false)
    private Date    createTime;

    //角色 -- 权限关系：多对多关系;
    @JsonIgnore
    @ManyToMany
    @JoinTable(name = "t_sys_role_permission",
            joinColumns = @JoinColumn(name = "role_id"),
            inverseJoinColumns = @JoinColumn(name = "permission_id"))
    private List<SysPermission> permissionList = new LinkedList<>();

    @Transient
    private Boolean isSelected;
}
